package cn.yunhe.busi.impl;

import cn.yunhe.busi.BookBusi;
import cn.yunhe.dao.AddBookDao;
import cn.yunhe.model.Book;
import org.apache.ibatis.session.SqlSession;
import util.SqlSessionFactoryUtil;

/**
 * Created by Administrator on 2018/4/13.
 */
public class BookBusiImpl implements BookBusi {
    @Override
    public boolean addBook(Book book) {
        SqlSession session = SqlSessionFactoryUtil.getSession();
        boolean flag = false;
        try {
            AddBookDao addBookDao = session.getMapper(AddBookDao.class);
            int result = addBookDao.addBook(book);
            session.commit();
            if (result>0){
                flag = true;
            }
        } catch (Exception e){
            e.printStackTrace();
        } finally {
            session.close();
        }
        return flag;
    }
}
